Low RAM space, high-throughput persistent key value store using secondary memory

ABSTRACT

Described is using flash memory (or other secondary storage), RAM-based data structures and mechanisms to access key-value pairs stored in the flash memory using only a low RAM space footprint. A mapping (e.g. hash) function maps key-value pairs to a slot in a RAM-based index. The slot includes a pointer that points to a bucket of records on flash memory that each had keys that mapped to the slot. The bucket of records is arranged as a linear-chained linked list, e.g., with pointers from the most-recently written record to the earliest written record. Also described are compacting non-contiguous records of a bucket onto a single flash page, and garbage collection. Still further described is load balancing to reduce variation in bucket sizes, using a bloom filter per slot to avoid unnecessary searching, and splitting a slot into sub-slots.

CROSS-REFERENCE TO RELATED APPLICATION(S)

This application is a continuation of U.S. patent application Ser. No.12/908,153, filed Oct. 20, 2010, entitled “LOW RAM SPACE,HIGH-THROUGHPUT PERSISTENT KEY-VALUE STORE USING SECONDARY MEMORY”. Theentirety of this afore-mentioned application is incorporated herein byreference.

BACKGROUND

Flash media has advantages over RAM and hard disk storage, namely thatunlike RAM, flash media is persistent, and unlike hard disk storage,flash media provides much faster data access times, e.g., on the orderof hundreds or thousands of times faster than hard disk access. Manyapplications thus may benefit from the use of flash media.

However, flash media is expensive, at present costing ten to twentytimes more per gigabyte than hard disk storage. Further, flash devicesare subject to reduced lifetimes due to page wearing, whereby smallrandom writes (that also have relatively high latency) are notdesirable. What is desirable is a technology for using flash media (orother non-RAM, non-hard disk storage) that provides high performance,while factoring in cost considerations, efficiency and media lifetimes.

U.S. patent application Ser. No. 12/773,859, assigned to the assignee ofthe present invention and herein incorporated by reference, describes aflash-based or other secondary storage memory cache having these desiredcharacteristics, such as for use in storing key-value pairs. However,the amount of RAM used is on the order of six bytes (two signature bytesplus four pointer bytes) for each key-value pair maintained in secondary(e.g., flash) storage. Reducing the amount of RAM used is desirable inmany scenarios.

SUMMARY

This Summary is provided to introduce a selection of representativeconcepts in a simplified form that are further described below in theDetailed Description. This Summary is not intended to identify keyfeatures or essential features of the claimed subject matter, nor is itintended to be used in any way that would limit the scope of the claimedsubject matter.

Briefly, various aspects of the subject matter described herein aredirected towards a technology by which a secondary storage device (e.g.,in flash memory) contains buckets of linked record, in which the bucketfor a record is determined by mapping the record's key to a RAM-basedindex having slots corresponding to pointers to the buckets. There aremore possible keys than slots/buckets, resulting in collisions that arehandled by searching the bucket in a most-recent to least-recentordering until a match is found, (if any exists).

To maintain the ordering, each record is associated with a pointer tothe previous record in its bucket, and so on, forming a linked list ofrecords. When a new record is inserted into the secondary storage, theprevious pointer in the RAM-based index is associated with the record tobe inserted (e.g., as part of a page write that includes the newrecord), and the index updated to point to the new record, therebymaintaining the linked list ordering.

In one aspect, a counter may be associated with each slot of the indexto indicate the size of the chain of records in the bucket thatcorresponds to that slot. If the size is too large, compaction may beperformed to writes a plurality of non-contiguous records of a bucket toa single page of contiguous records.

In one aspect, a bloom filter may be associated with each slot toindicate to a high probability whether a key of a record is in thebucket that corresponds to that slot. If not, the bucket need not besearched for that key.

In one alternative, a load balancing mechanism may operate to balancechain sizes in the buckets. For example, a key to be inserted may bemapped by multiple mapping functions to multiple candidate slots, withone candidate slot selected based upon the chain sizes of the candidatebuckets. The key is then inserted into the bucket that corresponds tothe selected slot. A bloom filter may be used to avoid searching bothcandidate buckets when later looking up that record.

In one alternative, the index may comprise a first index component and asecond index component. Individual slots in the first index may beconfigured to indicate that a key mapped to such a slot in the firstindex by a first mapping function is to be secondarily mapped to a slotin the second index by a second mapping function. This facilitatessplitting a slot in the first index into sub-slots, such as if the firstindex slot corresponds to too many keys.

Other advantages may become apparent from the following detaileddescription when taken in conjunction with the drawings.

BRIEF DESCRIPTION OF THE DRAWINGS

The present invention is illustrated by way of example and not limitedin the accompanying figures in which like reference numerals indicatesimilar elements and in which:

FIG. 1 is a block diagram representing an example architecture and datastructures for mapping records to secondary storage using a relativelysmall-sized RAM footprint.

FIG. 2 is a flow diagram representing example steps for looking up arecord key (e.g., of a key-value pair), including in secondary storage.

FIG. 3 is a flow diagram representing example steps for inserting akeyed record into secondary storage (as part of a page of records).

FIG. 4 is a representation of a data structure that maintains countersin association with pointers of an index table.

FIG. 5 is a flow diagram representing example steps for compacting achain of records onto a single page in secondary storage.

FIG. 6 is a block diagram representing an example architecture and datastructures illustrating compaction and garbage collection.

FIG. 7 is a block diagram representing an example architecture and datastructures illustrating load balancing.

FIG. 8 is a representation of a data structure that maintains bloomfilters and counters in association with pointers of an index table.

FIG. 9 is a block diagram representing an example architecture and datastructures illustrating splitting of an index slot in a first indextable into a plurality of slots in a second index table.

FIG. 10 shows an illustrative example of a computing environment intowhich various aspects of the present invention may be incorporated.

DETAILED DESCRIPTION

Various aspects of the technology described herein are generallydirected towards using secondary storage (e.g., flash media storage) ina manner that uses only a relatively very small-sized RAM footprintcompared to other technologies, such as for storing key-value pairs. Tothis end, key-value pairs are mapped by their keys into buckets (ofchained records) in sequential secondary storage, with a chain ofpointers that relate records of each bucket to the other entries in thatbucket. Mapping collisions are thus placed into the same bucket, whichis searched to find a matching key. As a result, instead of maintainingpointers in RAM, many of the pointers are maintained in the secondarystorage. In one implementation, this results in a RAM footprint on theorder of one (plus or minus one-half) byte of RAM per key-value pair.

It should be understood that any of the examples herein arenon-limiting. Indeed, the technology described herein applies to anytype of non-volatile storage that is faster than disk access, not onlythe flash media exemplified and referred to as an example herein. Thus,as used herein, “flash” is only an example that does not necessarilymean conventional flash media, but in general refers to any secondarystorage (with conventional RAM considered primary storage). Moreover,the data structures described herein are only examples; indeed, thestorage of any keyed records, not necessarily key-value pairs, maybenefit from the technology described herein. As such, the presentinvention is not limited to any particular embodiments, aspects,concepts, structures, functionalities or examples described herein.Rather, any of the embodiments, aspects, concepts, structures,functionalities or examples described herein are non-limiting, and thepresent invention may be used in various ways that provide benefits andadvantages in computing and data storage and retrieval in general.

FIG. 1 shows example architectural components of one implementation of akey-value store maintained using relatively very fast RAM 102 andnon-volatile secondary storage 104 (e.g., relatively fast compared tohard disk storage), which may be configured in flash media arranged aspages. In one implementation, the secondary storage 104/flash store isbasically arranged as a sequential log/file. More particularly, theflash store provides persistent storage for the keyed records (e.g.,key-value pairs), and in one implementation is organized as a circularappend log. Key-value pairs are written to flash in units of a page sizeto the tail of the log. When the log accumulates garbage (comprisingdeleted records, older values of updated records and/or orphanedrecords, described below) beyond a configurable threshold, the pages onflash from the head of the log are recycled such that valid entries fromthe head of the log are written back to the end of the log. Alsodescribed below is compacting the records in a given bucket into asingle page on flash, which improves read performance, as describedbelow.

As generally as described in the aforementioned U.S. patent applicationSer. No. 12/773,859, the RAM 102 includes a write buffer 106 comprisingan (e.g., fixed-size) data structure that buffers key-value writes sothat a write to flash happens only after there is enough data to fill aflash page (which is typically 2 KB or 4 KB in size). As also describedtherein, writes also may occur upon a configurable timeout intervalbeing reached.

The RAM 102 also includes an index data structure (directory),exemplified as an index table 108, which has pointers (each being acombination of a page pointer and a page offset) to key-value pairsstored on the secondary storage 104. A key mapping mechanism/function110, such as comprising a hash function or range-mapping function, mapseach key of key-value pairs 1121-112 m to one of N slots (each slotcorresponding to a bucket) in the index table 108, where N may beconfigurable for a given implementation thereby controlling the amountof RAM used for indexing. In other words, the hash function or rangemapping function maps any key value to one slot of a plurality thereof,in which the number depends on the mapping function, and is thusconfigurable.

Each slot contains a pointer to a chain (linked list) of one or morerecords in the secondary storage 104. The records thus include a pointerfield that forms the chain. More particularly, in addition to the keyand value fields, each key-value pair record in the secondary storage104 contains a pointer to the next record (in the order in itsrespective chain), that is, the previous record (key-value pair) in thesequential log that was mapped to the same slot as the new key-valuepair. The chain of records on flash pointed to by each slot thuscomprises the bucket of records corresponding to that slot in the indextable 108.

Thus, as is understood, mapping collisions are resolved by linearchaining with the chains stored in flash. The average number of recordsin a bucket, k, is a generally configurable parameter. Moreparticularly, because the chain of key-value pairs in each bucket istypically stored non-contiguously on flash, multiple flash reads may beincurred upon lookup of a key in the store. Lookup time versus RAM spaceoverhead per key-value pair is a tradeoff. The average number of keys ina bucket k is a configurable parameter that allows controlling thetradeoff between RAM space usage versus lookup times.

By way of further explanation, consider the following sequence ofaccesses in key lookup and insert operations performed by a clientapplication, as generally summarized in the flow diagrams of FIGS. 2 and3, respectively. As represented by step 202 of FIG. 2, a key lookup(get) operation first looks for a key in the RAM write buffer 106. Upona miss (step 204), the operation moves to step 206 to look up the key inthe index table 108 to find a pointer to the location in secondarystorage 104 of the most recent record written to that bucket. Forexample, a lookup operation on a key uses the hash mapping or rangemapping function to determine the index table slot to which the givenkey belongs, with the pointer in that slot identifying the startingaddress in secondary storage of that key's bucket.

Beginning with the pointer stored in that slot, the lookup operationfollows the chain of records on flash to search for the key, e.g., byreading the appropriate page and searching that page for the matchingkey. If that page does not contain the matching key, step 212 repeatsthe process using the pointer in the key's record at that address; (notethat a new page only need be read in if the pointer is to a new page).Upon finding the first record in the chain whose key matches the searchkey, the lookup operation returns the value associated with that key, asrepresented by step 214; (if there is no matching key, null is returnedvia step 216). The number of flash reads for such a lookup is k/2 on theaverage, and in the worst case is the size k of the bucket chain.

As generally represented in FIG. 3, a key insert (or, update/set)operation writes (step 302) the key-value pair into the RAM write buffer106. As represented by step 304, when there are enough key-value pairsin the RAM write buffer 106 to fill a flash page (or, a configurabletimeout interval since the client call has expired at step 306, such ason the order of one millisecond), the buffered entries are written tothe secondary storage 104. To this end, at step 308, for each key-valuepair to be written to the secondary storage 104, the pointer that waspreviously in that key's slot is also written to the secondary storage104 at step 310, e.g., as a <Key, Value, PTR> record in the page. Atstep 312, the pointer in the index table slot is changed to point to theaddress of that newly written key-value pair. Note that in building thepage, ordering is kept so that the index table points to themost-recently inserted record, and that record points to the next mostrecent, and so on.

To summarize, for a given key, the insert operation uses the mappingfunction to determine the index table slot to which that key belongs.For example, if a1 represents the address on flash of the first recordin this chain (that is, what the pointer in the slot currently pointsto), then a record is created in flash that corresponds to the inserted(or, updated) key-value pair with its next-pointer field equal to a1.This record is appended to the log on flash at its own flash address a2;and the a2 address on flash placed as the value of the pointer in therespective slot in RAM. Effectively, this newly written record isinserted at the beginning of the chain corresponding to this bucket.

Note that if the insert operation corresponds to an update operation onan earlier-inserted key, the most recent value of the key will be(correctly) read during a lookup operation because it will be reached byfollowing the chain, which links from most recent to older writtenrecords. Any older key will not be reached before the more recent one,because the old value is further down the chain; the older key will becleaned up as garbage in the log, as described below.

A delete operation on a key is supported through insertion of a nullvalue for that key. Eventually the null entries and any earlier-insertedvalues of a key on flash are garbage collected. In one implementation,when flash usage and/or the fraction of garbage records in the flash logexceed a certain threshold, a garbage collection (and compaction)operation is initiated to reclaim storage on flash.

Turning to maintenance operations, namely compaction and garbagecollection, as will be understood, compaction is useful in improvinglookup latencies by reducing the number of flash reads when searching abucket. Garbage collection reclaims storage on flash, and is aconsequence of flash being used in a log-structured manner.

With respect to compaction, as described above, a lookup operationinvolves following the chain of key-value records in a bucket on flash.For a chain length of c records in a bucket, this involves an average ofc/2 flash reads. Over time, as keys are inserted into a bucket andearlier inserted keys are updated, the chain length for this bucketkeeps increasing, which degrades lookup times. This situation may beaddressed by periodically compacting the chain on flash in a bucket,which in general places the valid keys in that chain (those that werenot deleted or updated with a new value) contiguously on one or moreflash pages that are appended to the tail of the log. Thus, if mkey-value pairs can be packed onto a single flash page (on the average),the number of flash reads required to search for a key in a bucket of krecords is k/(2 m) on the average and at most [k/m] in the worst case.Note that key-value pairs that have been compacted remain in theirprevious location on flash until garbage collected; these are referredto as orphaned key-value pairs.

In order to determine whether to compact a bucket of chained key-valuepairs, rather than following each chain and counting its length, acounter (Ctr) may be maintained in the index table for each slotcorresponding to that bucket. This is generally represented in the indextable 408 of FIG. 4 (although other arrangements to associate the datamay be alternatively employed) by counters Ctr1-CtrN associated withpointers Ptr1-PtrN for N slots. In general, the counter may be one bytein length and is incremented to match the chain size of non-compactedrecords, up to its limit.

The compaction operations may proceed over time, such as per slot/bucketas shown in FIG. 5, e.g., via a compaction mechanism 660 (FIG. 6),(which may be integrated with a garbage collection mechanism describedbelow). Initially, as key-value pairs are added at different times to abucket, they appear on different flash pages and are chained togetherindividually on flash. When enough valid records accumulate in a bucketto fill a flash page (e.g., m of them as evaluated at step 502), such astracked by the slot's counter, the records are compacted and appendedonto a new flash page, such as at the tail of the log. To this end, thevalid records of the chain are found via steps 504, 506 and 510, andadded to a compaction buffer 606 (FIG. 6) in RAM at step 508. When therecords are buffered, the compaction buffer 606 is written to a flashpage and the index updated at the slot to point to that page (step 512).The chain now comprises a single flash page size and requires one flashread (instead of approximately m reads) to fully search.

Thereafter, as further records 661 and 662 are appended to a bucket asgenerally represented in FIG. 6, they are chained together individuallyand are searched before the compacted group of records in the chain,that is, before the flash page 664 (shown shaded in FIG. 6). Thus, oncecompacted, at any given time, the chain on flash for each bucket maybegin with a chained sequence of one or more individual records 661, 662followed by groups of compacted records, with each group appearing onthe same flash page (e.g., the page 664).

Over time, enough new records may accumulate in the bucket to allow themto be compacted to a second flash page, and so on. To this end, thecompaction process repeats, whereby the chain now comprises twocompacted flash pages, and so on. Because an insert operation may make arecord on a compacted page invalid, previously compacted pages may bere-compacted.

Note that when a key-value pair size is relatively small, e.g., 64bytes, there may not be enough records in a bucket to fill a flash page,because this number is (roughly) upper bounded by the parameter k. Inthis case, the benefits of compaction may be obtained by applying theprocedure to groups of chains in multiple buckets at a time.

Because compaction copies records to the end of the log (or optionallyto another log) and accordingly adjusts the pointers, the originalrecords are not deleted, however there are no longer any pointers thatpoint to them. These no-longer-pointed-to records are referred to asorphaned records (a type of garbage) in the flash log. As mentionedabove, other garbage records also accumulate in the log as a result ofkey update and delete operations, that is, invalid records are present.These orphaned and invalid records are garbage collected.

In one implementation, the garbage collection operation starts scanningkey-value pairs from the (current) head of the log, and skips overgarbage (invalid or orphaned) key-value pair records while copying validkey-value pair records from the head to the tail of the log, includingadjusting pointers as appropriate for the new location. Once the validrecords of a page have been copied, that page can be reused when laterneeded in the circular log. Garbage collection may stop when floorthresholds are reached for flash usage and/or fraction of garbagerecords remaining in the flash log.

More particularly, when a certain configurable fraction of garbageaccumulates in the log (in terms of space occupied), a cleaningoperation is performed to clean and compact the log. The cleaningoperation considers currently used flash pages in oldest first order anddeallocates them. On each page, the sequence of key-value pairs isscanned to determine whether they are valid or not. The classificationof a key-value pair record on flash follows from doing a lookup on therespective key starting from the index table (if this record is the sameas that returned by the lookup, then it is valid). If it appears laterin the chain than a valid record for that key, then this record isinvalid and corresponds to an obsolete version of the key; otherwise,the record is orphaned and cannot be reached by following pointers fromthe index table (this may happen because of the compaction procedure,for example). When an orphaned record is encountered at the head of thelog, it is skipped and the head position of the log is advanced to thenext record. As described above with reference to the insertionoperation, the first record in each bucket chain (the one pointed tofrom the index table slot) is the most recently inserted record, whilethe last record in the chain is the earliest inserted record in thatbucket. Thus, the last record in a bucket chain is encountered firstduring the garbage collection process and it may be a valid or invalid(obsolete version of the respective key) record. A valid record needs tobe reinserted at the tail of the log, while an invalid record can beskipped. In either situation, the next pointer in its predecessor recordin the chain needs to be updated. To avoid in-place updates (randomwrites) on flash, this requires relocating the predecessor record and soforth all the way to the first record in the chain.

In one implementation, entire bucket chains on flash are garbagecollected at a time. When the last record in a bucket chain isencountered in the log during garbage collection, all valid records inthat chain are compacted and relocated to the tail of the log. In otherwords, when the garbage collector is invoked, scanning starts from the(current) head of the log and skips over orphaned records until itencounters the first valid or invalid record (that is part of somebucket chain). Then, the garbage collector collects that entire bucketchain, compacts and writes the valid records in that chain to the tailof the log, and returns.

This garbage collection strategy provides a benefit in that the writingof an entire chain of records in a bucket to the tail of the log alsoallows them to be compacted and placed contiguously on one or more flashpages, and helps to speed up the lookup operations on those keys.Another benefit is that because garbage (orphaned) records are createdfurther down the log between the (current) head and tail (correspondingto the locations of all records in the chain before relocation), thegarbage collection process is sped up for the respective pages when theyare encountered later, since orphaned records can be simply discarded.

Note that in one implementation, the client key lookup/insertoperations, writing key-value pairs to flash store and updating the RAMindex operations, and reclaiming space on flash pages operations, areeach handled by separate threads in a multi-threaded architecture.

Turning to an alternative aspect generally represented in FIG. 7, loadbalancing may be used to reduce variations in bucket sizes, (whichcorrespond to chain lengths and associated lookup times). Otherwise, themapping of keys to buckets may lead to skewed distributions in thenumber of keys in each bucket chain, thus creating variations in averagelookup times across buckets. Load balancing of keys across buckets maybe used to keep each bucket chain about the same size.

One straightforward way to achieve this is to use a known power of(e.g., two) choice idea. For example, with a load balanced design for ahash table mapping function, each key (e.g., 1121 in FIG. 7) may behashed to two candidate hash table directory buckets, using two hashfunctions 710A and 710B. The counter in the index table 708, whichtracks the size of the chain, may be accessed by load balance logic 770.The candidate bucket with the lesser number of keys is selected forappending the record to that bucket, and its corresponding slot counterincremented. In the example of FIG. 7, the selected slot/bucket isrepresented by the solid line from key mapping function 710A (ratherthan the dashed line from 710B).

The above-described load balancing alternative, without more, leads toan increase in the number of flash reads needed during lookup. That is,for a lookup operation, each key may need to be searched for in both ofits candidate buckets, whereby the average as well as worst case numberof flash reads (and thus corresponding lookup times) doubles.

To avoid this latency, as generally represented in FIG. 8, a bloomfilter may be added per index table slot that summarizes the keys thathave been inserted in the respective bucket, whereby (most of the time,to a relatively high probability) only one bucket chain on flash needsto be searched during a lookup. In general, a bloom filter contains anentry that either guarantees that a key is not in a chain, or to a highprobability indicates that a key may be in a chain; that is, there areno false negatives, although there may be false positives.

Note that the bloom filter in each slot can be sized based on desiredcharacteristics, e.g., to contain about k keys, because load balancingensures that when the hash table reaches its budgeted full capacity,each bucket will contain not many more than k keys (with very highprobability). Dimensioning a bloom filter to use one byte per key givesa false positive probability of two percent; hence the bloom filter ineach slot may be of size k bytes. A larger bloom filter decreases thefalse positive rate, but at the cost of memory, and vice-versa.

Moreover, the introduction of bloom filters has another desirable sideeffect, namely that lookups on non-existent keys will (almost always)not require any flash reads, because the bloom filters in both candidateslots of the key will likely indicate when a key is not present, andonly rarely suggest that a key may be present when it is actually not.This is in contrast to not having bloom filters, in which lookups fornon-existent keys lead to flash reads that involve traversing the entirechain in the respective bucket; (indeed, bloom filters may be usedwithout load balancing, including with or without counters, for avoidinglooking up non-existent keys).

Still further, while having bloom filters in each bucket reduce lookuptimes when two-choice load balancing is used, bloom filters themselvesalso benefit from load balancing. More particularly, load balancing aimsto keep the number of keys in each bucket upper bounded (roughly) by theparameter k. This helps to keep bloom filter false positiveprobabilities in that bucket bounded, as per the dimensioned capacity ofk keys. Without load balancing, many more than k keys may be insertedinto a given bucket, which increases the false positive rates of therespective bloom filter well beyond that for which it was dimensioned.

The additional fields added to each slot in the index table arerepresented in FIG. 8, e.g., with k bytes per bloom filter (BF), onebyte per chain size counter (Ctr), and four bytes per pointer (Ptr) inone implementation. During a lookup operation, the key is mapped to itstwo candidate directory buckets, with the chain on flash being searchedonly if the respective bloom filter indicates that the key may be inthat bucket. Thus, accounting for bloom filter false positives, thechain on flash will be searched with no success in less than two percentof the lookups, given a bloom filter dimensioned as described above.

Note that when load balancing and an insert operation corresponds to anupdate of an earlier inserted key, the record is inserted in the samebucket as the earlier one, even if the choice determined by loadbalancing (out of two candidate buckets) is the other bucket. Otherwisethe key may be inserted in the bloom filters of both candidate slots,which may cause traversing of more than one bucket chain on flash duringlookups. Moreover, a similar problem arises with version resolutionduring lookups if different versions of a key are allowed to be insertedin both candidate buckets. This also leads to efficiencies duringgarbage collection operations because the obsolete values of a keyappear in the same bucket chain on flash. Note that overriding of theload balancing-based choice of insertion bucket can be avoided when theapplication does not perform updates to earlier inserted keys, whichoccurs in certain applications, such as storage deduplication.

As can be readily appreciated, the amount of RAM space used is reducedin the implementations described herein. For example, consider that thepointer to flash in each slot is four bytes, which accommodates up to 4GB of a byte-addressable log. If records are of a fixed size such assixty-four bytes, then this can accommodate up to 256 GB of 64-bytegranularity addressable log. (Larger pointer sizes can be used accordingto application requirements.) Then, with an average bucket size value ofk=10, the RAM space overhead is only 4/k=0.4 bytes=3.2 bits per entry,independent of key-value size. The average number of flash reads perlookup is k/2=5; with current flash media achieving flash read times inthe range of 10 microseconds, this corresponds to a lookup latency ofabout 50 microseconds. The parameter k thus provides a mechanism forachieving tradeoffs between low RAM space usage and low lookuplatencies.

In an implementation having bloom filters, the RAM space overhead perbucket has three components, e.g., a k-byte bloom filter, a one-bytechain size counter, and a four-byte pointer. This space overhead perslot is amortized over an average of k keys (in that bucket), wherebythe RAM space overhead per entry is computed as (k+1+4)/k=1+5/k, whichis about 1.5 bytes for k=10. The average number of flash reads perlookup is k/2=5 (with high probability). Moreover, the variation acrosslookup latencies for different keys is more controlled in thisimplementation, (compared to a non-bloom filter implementation), asbucket chains are about the same size due to load balancing of keysacross buckets.

Turning to another alternative, FIG. 9 shows an implementation in whicha slot 990 in a first index table 908 corresponding to a bucket insecondary storage is mapped by a second mapping function 992 to asub-slot in a second index table 909 corresponding to a sub-bucket. Ingeneral, this splitting via secondary mapping may be used when a bucketbecomes too large with respect to the number of records therein.

By way of example, consider that the first mapping function is a rangemapping function that maps keys to a slot based on their range, e.g.,using simple numbers, keys having values between one and ten go to slotone, keys between eleven and twenty go to slot two, and so on. If thecounter associated with a given slot exceeds some splitting value, thenthat slot/bucket is split by a second mapping function, e.g., keysbetween eleven and fifteen go to sub-slot 995 while keys between sixteenand twenty go to sub-slot 996. The pointer (or another indicator) in thefirst index table may be used to tell whether for a given key thepointer points directly to the secondary storage bucket or indicates theneed to use the second mapping function to find a sub-bucket pointer ina sub-slot.

Note that while the simplified example above used a basic dividing of arange into two halves, a more complex function may be used. For example,a dynamic B+ treeload balancing function or the like may be used tosplit a bucket more evenly such that the sub-slot/sub-bucket countsdetermine how to divide the keys, e.g., keys eleven to thirteen may bein one sub-bucket, and keys fourteen to twenty another; this mayreadjust as needed. Moreover, more than two sub-slots/sub-buckets perprimary slot also may be used.

Note that the above splitting operation involves changing pointers,which can be relatively complex. However, the above-described compactionprocess inherently adjusts pointers, and thus compacting the records ineach sub-bucket (e.g., sub-range) may be performed to automaticallyadjust the pointers.

One benefit of range mapping is locality. For example, the key-valuepairs coming from the same website or other source may have keys thatare numerically close to one another. Lookups may occur on such keysaround the same time. By range mapping and compacting, flash reads maybe reduced, because numerically close keys, often looked up around thesame time, will be on the same compacted page in many instances.

Exemplary Operating Environment

FIG. 10 illustrates an example of a suitable computing and networkingenvironment 1000 on which the examples of FIGS. 1-9 may be implemented.The computing system environment 1000 is only one example of a suitablecomputing environment and is not intended to suggest any limitation asto the scope of use or functionality of the invention. Neither shouldthe computing environment 1000 be interpreted as having any dependencyor requirement relating to any one or combination of componentsillustrated in the exemplary operating environment 1000.

The invention is operational with numerous other general purpose orspecial purpose computing system environments or configurations.Examples of well-known computing systems, environments, and/orconfigurations that may be suitable for use with the invention include,but are not limited to: personal computers, server computers, hand-heldor laptop devices, tablet devices, multiprocessor systems,microprocessor-based systems, set top boxes, programmable consumerelectronics, network PCs, minicomputers, mainframe computers,distributed computing environments that include any of the above systemsor devices, and the like.

The invention may be described in the general context ofcomputer-executable instructions, such as program modules, beingexecuted by a computer. Generally, program modules include routines,programs, objects, components, data structures, and so forth, whichperform particular tasks or implement particular abstract data types.The invention may also be practiced in distributed computingenvironments where tasks are performed by remote processing devices thatare linked through a communications network. In a distributed computingenvironment, program modules may be located in local and/or remotecomputer storage media including memory storage devices.

With reference to FIG. 10, an exemplary system for implementing variousaspects of the invention may include a general purpose computing devicein the form of a computer 1010. Components of the computer 1010 mayinclude, but are not limited to, a processing unit 1020, a system memory1030, and a system bus 1021 that couples various system componentsincluding the system memory to the processing unit 1020. The system bus1021 may be any of several types of bus structures including a memorybus or memory controller, a peripheral bus, and a local bus using any ofa variety of bus architectures. By way of example, and not limitation,such architectures include Industry Standard Architecture (ISA) bus,Micro Channel Architecture (MCA) bus, Enhanced ISA (EISA) bus, VideoElectronics Standards Association (VESA) local bus, and PeripheralComponent Interconnect (PCI) bus also known as Mezzanine bus.

The computer 1010 typically includes a variety of computer-readablemedia. Computer-readable media can be any available media that can beaccessed by the computer 1010 and includes both volatile and nonvolatilemedia, and removable and non-removable media. By way of example, and notlimitation, computer-readable media may comprise computer storage mediaand communication media. Computer storage media includes volatile andnonvolatile, removable and non-removable media implemented in any methodor technology for storage of information such as computer-readableinstructions, data structures, program modules or other data. Computerstorage media includes, but is not limited to, RAM, ROM, EEPROM, flashmemory or other memory technology, CD-ROM, digital versatile disks (DVD)or other optical disk storage, magnetic cassettes, magnetic tape,magnetic disk storage or other magnetic storage devices, or any othermedium which can be used to store the desired information and which canaccessed by the computer 1010. Communication media typically embodiescomputer-readable instructions, data structures, program modules orother data in a modulated data signal such as a carrier wave or othertransport mechanism and includes any information delivery media. Theterm “modulated data signal” means a signal that has one or more of itscharacteristics set or changed in such a manner as to encode informationin the signal. By way of example, and not limitation, communicationmedia includes wired media such as a wired network or direct-wiredconnection, and wireless media such as acoustic, RF, infrared and otherwireless media. Combinations of the any of the above may also beincluded within the scope of computer-readable media.

The system memory 1030 includes computer storage media in the form ofvolatile and/or nonvolatile memory such as read only memory (ROM) 1031and random access memory (RAM) 1032. A basic input/output system 1033(BIOS), containing the basic routines that help to transfer informationbetween elements within computer 1010, such as during start-up, istypically stored in ROM 1031. RAM 1032 typically contains data and/orprogram modules that are immediately accessible to and/or presentlybeing operated on by processing unit 1020. By way of example, and notlimitation, FIG. 10 illustrates operating system 1034, applicationprograms 1035, other program modules 1036 and program data 1037.

The computer 1010 may also include other removable/non-removable,volatile/nonvolatile computer storage media. By way of example only,FIG. 10 illustrates a hard disk drive 1041 that reads from or writes tonon-removable, nonvolatile magnetic media, a magnetic disk drive 1051that reads from or writes to a removable, nonvolatile magnetic disk1052, and an optical disk drive 1055 that reads from or writes to aremovable, nonvolatile optical disk 1056 such as a CD ROM or otheroptical media. Other removable/non-removable, volatile/nonvolatilecomputer storage media that can be used in the exemplary operatingenvironment include, but are not limited to, magnetic tape cassettes,flash memory cards, digital versatile disks, digital video tape, solidstate RAM, solid state ROM, and the like. The hard disk drive 1041 istypically connected to the system bus 1021 through a non-removablememory interface such as interface 1040, and magnetic disk drive 1051and optical disk drive 1055 are typically connected to the system bus1021 by a removable memory interface, such as interface 1050.

The drives and their associated computer storage media, described aboveand illustrated in FIG. 10, provide storage of computer-readableinstructions, data structures, program modules and other data for thecomputer 1010. In FIG. 10, for example, hard disk drive 1041 isillustrated as storing operating system 1044, application programs 1045,other program modules 1046 and program data 1047. Note that thesecomponents can either be the same as or different from operating system1034, application programs 1035, other program modules 1036, and programdata 1037. Operating system 1044, application programs 1045, otherprogram modules 1046, and program data 1047 are given different numbersherein to illustrate that, at a minimum, they are different copies. Auser may enter commands and information into the computer 1010 throughinput devices such as a tablet, or electronic digitizer, 1064, amicrophone 1063, a keyboard 1062 and pointing device 1061, commonlyreferred to as mouse, trackball or touch pad. Other input devices notshown in FIG. 10 may include a joystick, game pad, satellite dish,scanner, or the like. These and other input devices are often connectedto the processing unit 1020 through a user input interface 1060 that iscoupled to the system bus, but may be connected by other interface andbus structures, such as a parallel port, game port or a universal serialbus (USB). A monitor 1091 or other type of display device is alsoconnected to the system bus 1021 via an interface, such as a videointerface 1090. The monitor 1091 may also be integrated with atouch-screen panel or the like. Note that the monitor and/or touchscreen panel can be physically coupled to a housing in which thecomputing device 1010 is incorporated, such as in a tablet-type personalcomputer. In addition, computers such as the computing device 1010 mayalso include other peripheral output devices such as speakers 1095 andprinter 1096, which may be connected through an output peripheralinterface 1094 or the like.

The computer 1010 may operate in a networked environment using logicalconnections to one or more remote computers, such as a remote computer1080. The remote computer 1080 may be a personal computer, a server, arouter, a network PC, a peer device or other common network node, andtypically includes many or all of the elements described above relativeto the computer 1010, although only a memory storage device 1081 hasbeen illustrated in FIG. 10. The logical connections depicted in FIG. 10include one or more local area networks (LAN) 1071 and one or more widearea networks (WAN) 1073, but may also include other networks. Suchnetworking environments are commonplace in offices, enterprise-widecomputer networks, intranets and the Internet.

When used in a LAN networking environment, the computer 1010 isconnected to the LAN 1071 through a network interface or adapter 1070.When used in a WAN networking environment, the computer 1010 typicallyincludes a modem 1072 or other means for establishing communicationsover the WAN 1073, such as the Internet. The modem 1072, which may beinternal or external, may be connected to the system bus 1021 via theuser input interface 1060 or other appropriate mechanism. A wirelessnetworking component such as comprising an interface and antenna may becoupled through a suitable device such as an access point or peercomputer to a WAN or LAN. In a networked environment, program modulesdepicted relative to the computer 1010, or portions thereof, may bestored in the remote memory storage device. By way of example, and notlimitation, FIG. 10 illustrates remote application programs 1085 asresiding on memory device 1081. It may be appreciated that the networkconnections shown are exemplary and other means of establishing acommunications link between the computers may be used.

An auxiliary subsystem 1099 (e.g., for auxiliary display of content) maybe connected via the user interface 1060 to allow data such as programcontent, system status and event notifications to be provided to theuser, even if the main portions of the computer system are in a lowpower state. The auxiliary subsystem 1099 may be connected to the modem1072 and/or network interface 1070 to allow communication between thesesystems while the main processing unit 1020 is in a low power state.

CONCLUSION

While the invention is susceptible to various modifications andalternative constructions, certain illustrated embodiments thereof areshown in the drawings and have been described above in detail. It shouldbe understood, however, that there is no intention to limit theinvention to the specific forms disclosed, but on the contrary, theintention is to cover all modifications, alternative constructions, andequivalents falling within the spirit and scope of the invention.

What is claimed is:
 1. A computing device, comprising: at least onememory, and at least one processor, wherein the at least one memory andthe at least one processor are respectively configured to store andexecute instructions for causing the computing device to performoperations, the operations comprising: maintaining, in a primarystorage, an index that correlates data in a persistent memory within asecondary storage; and mapping a particular key of a plurality ofpossible keys to a particular slot of the index, wherein the index has adefined quantity of slots, wherein a quantity of possible keys in theplurality of possible keys is greater than the defined quantity of slotsof the index, wherein the particular key corresponds to a particularrecord, wherein the particular slot is configured to maintain a pointerto a last written record in a corresponding bucket of one or morerecords arranged non-contiguously in the secondary storage, and whereineach record in the corresponding bucket corresponds to a pointer to aprevious record in the secondary storage, if the previous record exists,and to a key that maps to the particular slot.
 2. The computing deviceof claim 1, wherein the secondary storage comprises a flash devicearranged in pages.
 3. The computing device of claim 1, wherein theoperations further comprise: finding a record in the secondary storagebased upon an input key, including: determining another slot that ismapped to the input key; accessing the secondary storage based on thepointer maintained with the other slot; finding another bucket thatcorresponds to the other slot; and searching the other bucket for therecord that corresponds to a key that matches the input key.
 4. Thecomputing device of claim 3, wherein the other bucket comprises aplurality of records linked together, wherein a pointer in the otherslot points to the last record written to the other bucket, wherein eachrecord in the other bucket maintains a pointer to an earlier recordwritten to the other bucket, and wherein the operations furthercomprise: searching the other bucket by following a link from one recordto another record until a record that corresponds to the key thatmatches the input key is found, or until a record that does not have alink to another record is found.
 5. The computing device of claim 1,wherein the operations further comprise: inserting an input record intothe secondary storage, including: determining another slot that ismapped to another key that corresponds to the input record, wherein theinput record is associated with a previous pointer maintained in theother slot; and changing the previous pointer to a new pointer thatpoints to a location in the secondary storage where the input record iswritten.
 6. The computing device of claim 1, wherein the operationsfurther comprise at least one of a hash function, or a range mappingfunction.
 7. The computing device of claim 1, wherein the operationsfurther comprise: writing a plurality of records of another bucket tothe secondary storage.
 8. The computing device of claim 1, wherein theoperations further comprise: removing at least one of an invalid recordor an orphaned record from the secondary storage.
 9. The computingdevice of claim 8, wherein the operations further comprise: adding a newrecord to the secondary storage in a circular-log-structured manner witha head of a log and a tail of the log, wherein adding the new recordincludes: appending the new record to an end of the log; and copyingvalid records that are not invalid and not orphaned from the head of thelog to the tail of the log.
 10. A computing device, comprising: at leastone memory, and at least one processor, wherein the at least one memoryand the at least one processor are respectively configured to store andexecute instructions for causing the computing device to performoperations, the operations comprising: maintaining an index in a primarystorage that indexes data in a secondary storage; mapping a record's keyto one slot of the index, wherein there are more possible keys thanslots of the index, wherein each slot of the index is configured tomaintain a pointer to a corresponding bucket of one or morenon-contiguous records in a secondary storage, and wherein each recordin that slot's corresponding bucket has a key and at least one mappingfunction that maps to that slot; and indicating a probability as towhether a key of a record is in the bucket that corresponds to thatslot.
 11. The computing device of claim 10, wherein the operationsfurther comprise balancing chain sizes in the buckets.
 12. The computingdevice of claim 10, wherein the mapping comprises a plurality of hashfunctions that map keys to candidate slots, and a selection of a slotfrom among the candidate slots based at least in part upon the chainsize in the buckets corresponding to the candidate slots.
 13. Thecomputing device of claim 10, wherein the operations further compriseindicating a size of a chain of records in the bucket that correspondsto that slot.
 14. The computing device of claim 10, wherein thecorresponding bucket comprises a plurality of records linked together,wherein the pointer in the slot points to the last record written to thebucket, wherein each record in the bucket maintains a pointer to anearlier record written to the corresponding bucket.
 15. A method,comprising: maintaining, in a random access memory (RAM), an indexhaving pointers to buckets in a secondary storage, wherein the secondarystorage is maintained in a log-structured manner with new data appendedto an end of a log, and wherein each bucket comprises a linked list ofnon-contiguous records; inserting an input record into the secondarystorage including mapping a key of the input record to one of thebuckets, associating a previous pointer maintained in the index for thatbucket with the input record so as to link the input record to aprevious record, and changing the previous pointer to a new pointer thatpoints to a location in the secondary storage where the input record iswritten; and compacting a bucket, including writing data from records ofthe bucket into a compaction buffer, and writing the compaction bufferinto contiguous memory locations in the secondary storage.
 16. Themethod of claim 15, further comprising storing a plurality of inputrecords in a write buffer of the RAM; looking up a record by accessingthe write buffer and searching the plurality of input records for therecord having a matching key; and inserting the plurality of inputrecords into a full page of flash memory in the secondary storage. 17.The method of claim 16, wherein a counter is associated with a slot of aplurality of slots, wherein the counter indicates a size of a chain ofrecords in a particular bucket that corresponds to the slot.
 18. Themethod of claim 16, further comprising: searching a first page for therecord having the key that matches the key of the input record, and ifthe record is not located and a last searched record of the first pagehas a pointer to another page, repeating the searching for the otherpage.
 19. The method of claim 15, wherein mapping the key to the one ofthe buckets comprises: mapping the key to a slot that contains a pointerthat indicates whether the pointer points to a record or to an indexcomponent.
 20. The method of claim 19, wherein if the pointer points toa record, multiple records mapped to the slot form a chain on thesecondary storage, and if the pointer points to the index component,applying a second mapping mechanism to map the key to a second slot inthe index component, wherein multiple records that map to the slot inthe index component form a chain on the secondary storage.